<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
            width: 400px;
            margin: 100px auto;
            text-align: center;
            border-collapse: collapse;
        }
        thead tr{
            height: 30px;
            background-color: skyblue;
        }
        tbody tr{
            height: 30px;
        }
        tbody td{
            color: blue;
            font-size: 12px;
            border-bottom: 1px solid #d7d7d7;
        }
    </style>
</head>
<body>
    <table>
        <thead>
            <tr>
                <th><input type="checkbox" name="" id="checkAll"></th>
                <th>商品</th>
                <th>价格</th>
            </tr>
        </thead>
        <tbody id="checkitem">
            <tr>
                <td><input type="checkbox" name="" id=""></td>
                <td>IPONE8</td>
                <td>8000</td>
            </tr>
            <tr>
                <td><input type="checkbox" name="" id=""></td>
                <td>IPid Pro</td>
                <td>5000</td>
            </tr>
            <tr>
                <td><input type="checkbox" name="" id=""></td>
                <td>IPid Air</td>
                <td>2000</td>
            </tr>
            <tr>
                <td><input type="checkbox" name="" id=""></td>
                <td>Apple Watch</td>
                <td>2000</td>
            </tr>
        </tbody>
    </table>
    <script>
        var checkAll = document.getElementById('checkAll');
        var checkitems = document.getElementById('checkitem').getElementsByTagName('input');
        checkAll.onclick = function(){
            for(var i = 0; i < checkitems.length; i++){
                checkitems[i].checked = this.checked;
            }
        }
        for(var i = 0; i < checkitems.length; i++){
            checkitems[i].onclick = function(){
                var flag = true;
                for(var i = 0; i < checkitems.length; i++){
                    if(!checkitems[i].checked){
                        flag = false;
                    }
                }
                checkAll.checked = flag;
            } 
        }
    </script>
</body>
</html>